﻿@{
    ViewBag.Title = "用户首页";
    Layout = "../Shared/_Layout.cshtml";
}
<link href="~/Scripts/bootstrap-table/src/bootstrap-table.css" rel="stylesheet" />
<script src="~/Scripts/bootstrap-table/src/bootstrap-table.js"></script>
<script src="~/Scripts/bootstrap-table/src/locale/bootstrap-table-zh-CN.js"></script>
<body style="margin-left:10px">
    <p style="margin-top:10px">
        <div class="col-xs-2">
            <input type="text" class="form-control" placeholder="查询条件">
        </div>
        <button type="button" class="btn btn-default">查询</button>
        <button type="button" class="btn btn-primary" id="btnadd">新增</button>
        <button type="button" class="btn btn-success">修改</button>
        <button type="button" class="btn btn-danger">删除</button>
    </p>
    <table id="table" data-sort-order="desc" data-query-params="queryParams">
        <thead>
            <tr>
                <th data-field="state" data-checkbox="true"></th>
                <th data-field="name" data-formatter="nameFormatter" data-sortable="true">用户名</th>
                <th data-field="stargazers_count">Stars</th>
                <th data-field="forks_count">Forks</th>
                <th data-field="description" data-sortable="true">Description</th>
            </tr>
        </thead>
    </table>
    
    <script>
       

        $(function () {
            $("#btnadd").on("click", function () {
                layer.open({
                    type: 2,
                    title: '新增用户',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['800px', '520px'],
                    content: 'Add' //iframe的url
                });

            });
            $('#table').bootstrapTable({
                
                dataType: "json",
                url: "../User/GetUserList",
                striped: true,
                pageList: [20, 50, 100],
                pagination: true,//启用分页 
                queryParams: queryParams,//携带参数  
                pageSize: 20,
                sortName: "name",
                pageIndex: 0,//其实页  
                method: "get",//请求格式 
                sidePagination: "server",
                clickToSelect: true,//点击行即可选中单选/复选框  
                onPageChange: function (number, size) {
                    currPageIndex = number;
                    currLimit = size
                },
            });
        });


        //拼装发送到服务器的数据
        function queryParams(params) {
            console.log(params);
            return {
                pageSize: params.limit,
                pageoffset: params.offset,
            };
        }
        function nameFormatter(value) {
            return '<a href="https://github.com/">' + value + '</a>';
        }
    </script>
</body>

